import React, { useContext } from 'react'
import { Button } from 'antd'
import { connect } from 'react-redux'
// import { connect } from '../../myReactRedux'
import ThemeContext from '../../ThemeContext'
import action from '../../store-redux/actions'
import { bindActionCreators } from 'redux'

function VoteFooter(props) {
  // let { store } = useContext(ThemeContext)
  // let change = function change(type) {
  //   store.dispatch({
  //     type: type === 'sup' ? 'VOTE_SUP' : 'VOTE_OPP',
  //     step: 1
  //   })
  // }
  // return <div>
  //   <Button type='primary' onClick={change.bind(null, 'sup')}>支持</Button>
  //   <Button type='primary' danger onClick={change.bind(null, 'opp')}>反对</Button>
  // </div>

  // -------
  let { support, oppose } = props;
  return <div>
    <Button type='primary' onClick={support}>支持</Button>
    <Button type='primary' danger onClick={oppose}>反对</Button>
  </div>
}

export default connect(null, action.vote)(VoteFooter)

// export default connect(null, (dispatch) => {
  // console.log(bindActionCreators(action.vote, dispatch))

  // console.log(String(bindActionCreators(action.vote, dispatch).oppose))
//   return {
//     support() { },
//     oppose() { }
//   }
// })(VoteFooter)

// export default connect(null, (dispatch) => {
//   return {
//     support() {
//       dispatch(action.vote.support())
//     },
//     oppose() {
//       dispatch(action.vote.oppose())
//     }
//   }
// })(VoteFooter)